<!--#include file="../main/top.asp" -->
<%levelArray = userLevel()%>
<%
'用于搜索
if request("userLevel")="-1" then
	levelQuery = ""
else
	levelQuery = " and userLevel="&request("userLevel")
end if
if request("collegeid")="-1" or request("collegeid")="" or IsNull(request("collegeid")) then
	collegeidQuery=""
else
	collegeidQuery=" and collegeid="&request("collegeid")
end if
if request("userName")="" then
	userNameQuery = ""
else
	userNameQuery =" and userName like '%"&request("userName")&"%'"
end if
if request("realname")="" then
	realnameQuery = ""
else
	realnameQuery =" and realname like '%"&request("realname")&"%'"
end if
if request("telnum")="" then
	telnumQuery = ""
else
	telnumQuery =" and telnum like '%"&request("telnum")&"%'"
end if

'系统管理员、校级管理员
if levelArray(0)="0" or levelArray(0)="1" then
	if str_query("page")="" then
		sql = "select * from cw_users order by editTime desc"
	else
		sql = "select * from cw_users where 1=1 "&userNameQuery&realnameQuery&telnumQuery&levelQuery&collegeidQuery&" order by editTime desc"
	end if
'院级管理员
elseif levelArray(0)="2" then
	if str_query("page")="" then
		sql = "select * from cw_users where userLevel in (2,3) and collegeid="&levelArray(1)&" order by editTime desc"
	else
		sql = "select * from cw_users where collegeid="&levelArray(1)&userNameQuery&realnameQuery&telnumQuery&levelQuery&" order by editTime desc"
	end if
end if 
'echo sql
page_size = 20
paper = pageturner_handle(sql,"userId",page_size)
set rs = paper(0)
%>
<div class="function_title"><span class="t2"><img src="../images/dqwz.gif">当前位置：用户管理</span></div>
<div class="function_content">

<div class="addItem"><img src="../images/insert_icon.gif"><a href="adminUsersAdd.asp">添加用户</a>
<img src="../images/edit_icon.png"><a href="../adminUsers/adminUsersList.asp">用户管理</a>  
<img src="../images/edit_icon.png"><a href="../adminRoles/adminRolesList.asp">角色管理</a>
<img src="../images/edit_icon.png"><a href="../adminOperations/adminOperationsList.asp">操作管理</a>
</div>

<div class="search_function">
<form action="adminUsersList.asp" method="get" name="search_form" id="search_form" >
<div class="sub_form">用户名：<input type="text" name="userName" id="userName" value="<%=request("userName")%>"></div>
<div class="sub_form">真实姓名：<input type="text" name="realName" id="realName" value="<%=request("realName")%>"></div>
<div class="sub_form">联系方式：<input type="text" name="telNum" id="telNum" value="<%=request("telNum")%>"></div>
<div class="sub_form">用户级别：
<select name="userLevel" id="userLevel">
	<option value="-1">全部</option>
    <%
	if levelArray(0)=0 or levelArray(0)=1 then
		if request("userLevel")=1 then
			echo "<option value='1' selected='selected'>校级</option>"
		else
			echo "<option value='1'>校级</option>"
		end if
	end if
	if request("userLevel")=2 then
		echo "<option value='2' selected='selected'>院级</option>"
	else
		echo "<option value='2'>院级</option>"
	end if
'	if request("userLevel")=3 then
'		echo "<option value='3' selected='selected'>班级</option>"
'	else
'		echo "<option value='3'>班级</option>"
'	end if
	%>
</select>
</div>
<div class="sub_form">所管学院：
<select name="collegeid" id="collegeid">
	<%
	if levelArray(0)=0 or levelArray(0)=1 then
		echo "<option value='-1'>全部</option>"
		call showCollegeOptionListByCollegeid(-1,request("collegeid"))
	elseif levelArray(0)=2 then
		echo showOneCollegeOption(levelArray(1))
	end if
	%>
</select>
</div>
<div class="sub_form"><input type="submit" value="搜索" class="button"></div>
</form>
</div>

<div class="show_table_content">
<form method="post" name="adminUsersDelByCommon" id="adminUsersDelByCommon" action="adminUsersDel.asp" >
<input type="submit" name="submit" value="删除选中记录" class="button" onClick="return p_del();"/>
<%=pageturner_show(paper(1),paper(2),paper(3),page_size,5)%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="listTable">
  <tr class="title_line">
    <td><input type="checkbox" name="select_all" id="select_all" onClick="checkAll()" class="input_noborder"></td>
    <td>序号</td>
    <td>用户名</td>
    <td>真实姓名</td>
    <td>联系方式</td>
    <td>角色列表</td>
    <td>用户级别</td>
    <td>所管学院</td>
    <td>添加时间</td>
    <td>更新时间</td>
    <td>操作</td>
  </tr>
<%
i = 1
'循环显示出所有管理员信息
if not rs.eof then
do while not rs.eof
%>
  <tr>
  	<td><input type="checkbox" name="id" id="allid" value="<%=rs("userId")%>" class="input_noborder"></td>
    <td><%=i%></td>
    <td><%=rs("userName")%></td>
    <td><%=rs("realName")%></td>
    <td><%=rs("telNum")%></td>
    <td><%=showRoleListByRoleCollection(rs("roleCollection"))%></td>
    <td><%=showLevel(rs("userLevel"))%></td>
    <td><%=showCollegename(rs("collegeid"))%></td>
    <td><%=rs("addTime")%></td>
    <td><%=rs("editTime")%></td>
    <td><a href="adminUsersEdit.asp?id=<%=rs("userId")%>">修改</a> <a href="adminUsersDel.asp?id=<%=rs("userId")%>" onClick="return p_del();">删除</a></td>
  </tr>
<%
i=i+1
rs.movenext
loop
end if
rs.close : set rs = nothing
conn.close : set conn=nothing
%>
</table>
<%=pageturner_show(paper(1),paper(2),paper(3),page_size,5)%>
<input type="submit" name="submit" value="删除选中记录" class="button" onClick="return p_del();"/>
</form>
</div>
</div>
<!--#include file="../main/bottom.asp" -->